//
//  ZyaHomeNavView.swift
//  ZYA
//
//  Created by 邱仙凯 on 2024/12/3.
//  Copyright © 2024 zwb. All rights reserved.
//

import UIKit

class ZyaHomeNavView: UIView {
     var searchBar:UISearchBar?
    lazy var iconButton: UIButton = {
        let button = UIButton()
        button.setImage(#imageLiteral(resourceName: "icon_t"), for: UIControl.State())
        return button
    } ()
    lazy var setButton: UIButton = {
        let button = UIButton()
        button.setImage(#imageLiteral(resourceName: "set_t"), for: UIControl.State())
        return button
    } ()
    lazy var saoButton: UIButton = {
        let button = UIButton()
        button.setImage(#imageLiteral(resourceName: "sao_t"), for: UIControl.State())
        return button
    } ()
    lazy var searchButton: UIButton = {
        let v = UIButton()
        v.setTitle("搜索", for: .normal)
        v.titleLabel?.font = UIFont.boldSystemFont(ofSize: 14)
        v.setTitleColor(Theme.primaryColor(), for: .normal)
        return v
    } ()
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        iconButton.extRadius(radius: 35/2.0).extMaskBounds(mask: true)
        addSubview(iconButton)
        iconButton.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(10)
            make.width.height.equalTo(35)
            make.centerY.equalToSuperview()
        }
        
        addSubview(setButton)
        setButton.snp.makeConstraints { make in
            make.right.equalToSuperview().offset(-10)
            make.width.height.equalTo(35)
            make.centerY.equalToSuperview()
        }
 
        
       let seaBg = UIView()
        seaBg.backgroundColor = .white
        seaBg.layer.cornerRadius = 17
        
        seaBg.addSubview(saoButton)
        seaBg.addSubview(searchButton)
        addSubview(seaBg)
        self.addSubview(seaBg)
        searchBar = TenderSearchBar()
        searchBar!.searchTextField.leftView = nil
        searchBar!.searchTextField.leftViewMode = .never

 
        seaBg.addSubview(searchBar!)
      
        seaBg.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(55)
            make.right.equalToSuperview().offset(-55)
            make.top.bottom.equalToSuperview()
        }
        searchBar!.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(25)
            make.right.equalToSuperview().offset(-45)
            make.top.bottom.equalToSuperview()
        }
        saoButton.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(6)
            make.width.height.equalTo(35)
            make.centerY.equalToSuperview()
        }
        searchButton.snp.makeConstraints { make in
            make.right.equalToSuperview().offset(-6)
            make.width.height.equalTo(35)
            make.centerY.equalToSuperview()
        }
        
    
        searchBar!.searchTextField.backgroundColor = UIColor.white
            searchBar!.searchTextField.layer.cornerRadius = 8
            searchBar!.searchTextField.layer.masksToBounds = true
     
        searchBar?.backgroundImage = UIImage()
        searchBar!.placeholder = "搜索"
        
    
        
  
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
